package com.ruicar.afs.cloud.basic.proceeds.debit.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruicar.afs.cloud.basic.proceeds.debit.entity.BasicDebitBatch;
import com.ruicar.afs.cloud.common.modules.contract.enums.YesOrNoEnum;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author: Lee
 * @date 2020-05-30 04:13:03 
 * @description 
 */
public interface BasicDebitBatchMapper extends BaseMapper<BasicDebitBatch> {

    /**
     * 扣款批次加锁解锁
     * @author ZC.GUO
     * @param var1 动作，锁定和解锁（锁定yes,解锁no)
     * @param var2 id
     * @return
     */
    @Update({"update basic_debit_batch set is_operating = #{action} where id = #{id} and is_operating <> #{action}"})
    @Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
    int updateWhenOperateDebitBatch(@Param("action") YesOrNoEnum var1, @Param("id") Long var2);


}
